package win.larryzeal.spring.jmx.server.jmxserverdemo.service;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Service;

import java.util.logging.Logger;

/**
 * Created by 张少昆 on 2017/8/23 0023.
 */
@Service
@ManagedResource( objectName = "win.larryzeal.spring.jmx.server.jmxserverdemo.service:type=Service,name=MyJavaObject", description = "Any java obj is OK!" )
public class MyJavaObject {

	private static final Logger LOG = Logger.getLogger("MyJavaObject");
	private long id;
	private String name;

	public MyJavaObject(){
		super();
	}

	public MyJavaObject(long id, String name){
		super();
		this.id = id;
		this.name = name;
	}

	@ManagedAttribute
	public long getId(){
		return id;
	}

	public void setId(long id){
		this.id = id;
	}

	@ManagedAttribute
	public String getName(){
		return name;
	}

	@ManagedAttribute
	public void setName(String name){
		this.name = name;
	}

	@ManagedOperation
	public String show(){
		StringBuffer sb = new StringBuffer().append("id=").append(id).append(", name=").append(name);
		LOG.info("show()=" + sb.toString());
		return sb.toString();
	}


}
